import java.util.Random;

//普通的图
public class Graph_1 {
    public int nodeNub ;
    public boolean[][] edge ;
    public Random random = new Random();
    public boolean[] flag ;
    public int[] color ;
    int colorNub ;

    public boolean[] getColor(int n){
        boolean[] a = new boolean[colorNub+1] ;
        for(int i=0;i<nodeNub;i++){
            if(edge[i][n]){
                a[color[i]] = true ;
            }
        }
        return a ;
    }

    //无参构造函数
    //随机生成图
    Graph_1(int n,int maxNub,int colorNub){
        this.nodeNub = n ;
        buildG(n,maxNub) ;
        this.colorNub = colorNub ;
    }

    private void buildG(int n,int maxNub){
        edge = new boolean[n][n] ;
        for(int i=1;i<n;i++){
            //先生成一棵树
            int rand = random.nextInt(n) ;
            edge[i][rand] = true ;
            edge[rand][i] = true ;
        }

        maxNub = maxNub - n+1 ;
        for(int i=0;i<maxNub;i++){
            //再加边进去
            int a = random.nextInt(n);
            int b = random.nextInt(n);
            edge[b][a] = true ;
            edge[a][b] = true ;
        }
    }

    public void travel(){
        flag = new boolean[nodeNub] ;
        for(int i=0; i<nodeNub;i++){
            for(int j=0;j<nodeNub;j++){
                if(edge[i][j]&&flag[j]){
                    System.out.println(i+"--->"+j+"\n");
                }
            }
            flag[i] = true ;
        }
    }

    public boolean[][] getEdge(){
        return edge ;
    }

    public int getNodeNub(){
        return nodeNub ;
    }
}
